package com.util;

import org.jdom.input.SAXBuilder;
import org.jdom.Document;
import org.jdom.Element;

import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 *
 * @author Xu Jianbo
 * @version 1.0
 *          Date: 2008-3-31
 *          Time: 14:53:38
 */
public class XMLUtil {

    public static void main(String[] args) {

        try {
            //String path = "http://192.168.41.167:8081/forsearch/search_xml.jsp?kw=%E5%A4%A7%E9%95%BF%E4%BB%8A&count=10";
            //String path="http://211.151.32.238:8080/xihttp_pptv_xml_movie.jsp?kw=%E6%97%A0%E6%9E%81";
        	String path = "http://125.39.193.75:8080/cms_jdh/servlet/CheckService?type=login&strTvId=SERIAL_TEST_SUCCESS_0";
            SAXBuilder sb = new SAXBuilder();
            URL url = new URL(path);
            InputStream is = url.openStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(is));
            Document document = sb.build(reader);
            Element rootElement = document.getRootElement();
            List<Element> list=rootElement.getChildren();
            if(list==null) return;
            for(Element e:list){
            	System.out.println(e.getValue());
             //   System.out.println(e.getChildText("name"));
             //   System.out.println(e.getChildText("piclink"));
            //    System.out.println(e.getChildText("link"));
            }

        } catch(Exception e) {
            e.printStackTrace();
        }
    }


}
